package com.doctorliang.cheng.shopping.community.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.doctorliang.cheng.shopping.R;
import com.doctorliang.cheng.shopping.base.BaseFragment;
import com.doctorliang.cheng.shopping.community.adapter.CommunityViewPagerAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

import static android.content.ContentValues.TAG;

/**
 * Created by CHENG on 2017/9/26.
 * 发现视图的Fragment
 */

public class CommunityFragment extends BaseFragment {
    @Bind(R.id.ib_community_icon)
    ImageButton ibCommunityIcon;
    @Bind(R.id.ib_community_message)
    ImageButton ibCommunityMessage;
    @Bind(R.id.tablayout)
    TabLayout tablayout;
    @Bind(R.id.view_pager)
    ViewPager viewPager;

    @Override
    public View initView() {
        View view = View.inflate(mcontext, R.layout.fragment_community, null);
        return view;
    }

    @Override
    public void initData() {
        super.initData();
        Log.e(TAG, "发现视图的数据被初始化了");
        CommunityViewPagerAdapter viewPagerAdapter = new CommunityViewPagerAdapter(getFragmentManager());
        viewPager.setAdapter(viewPagerAdapter);
        tablayout.setVisibility(View.VISIBLE);
        tablayout.setupWithViewPager(viewPager);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
